import { DescItem } from "@/components/GuatDescriptions/type";
import { SignInPropertyMap as SIPM } from "@/map/attendance/sign-in/property-map";
import { SignInRecordStatus as SIRS } from "@/constant/dictionary";
import { Table } from "@arco-design/web-vue";

export const basicInfoDesc: DescItem[] = [
  { label: "标题", path: SIPM.Title },
  { label: "创建时间", path: SIPM.CreateTime },
  { label: "创建人", path: `${SIPM.Creator}.userName` },
  { label: "开始时间", path: SIPM.StartTime },
  { label: "结束时间", path: SIPM.EndTime },
  {
    label: "是否允许请假",
    path: SIPM.AllowLeave,
    component: "Tag",
    componentProps: {
      color: (value) => (value ? "green" : "red"),
    },
    mapping: (value) => {
      return value ? "允许" : "不允许";
    },
  },
  {
    label: "当前状态",
    path: SIPM.Status,
    component: "Tag",
    componentProps: {
      color: (value) => {
        const color = {
          [SIRS.UNSTARTED]: "red",
          [SIRS.SIGNIN]: "green",
          [SIRS.FINISHED]: undefined,
        };
        return color[value as number];
      },
    },
    mapping: (value) => SIRS[value as 0],
  },
];

export const checkModalDesc: DescItem[] = [
  { label: "姓名", path: "name" },
  { label: "学号", path: "no" },
  {
    label: "签到状态",
    path: "status",
    component: "Tag",
    componentProps: {
      color: "green",
    },
  },
  { label: "签到时间", path: "time" },
  { label: "签到附件", path: "images", component: "ImageList" },
];

export const newSignInDesc: DescItem[] = [
  { label: "标题", path: SIPM.Title },
  { label: "开始时间", path: SIPM.StartTime },
  { label: "结束时间", path: SIPM.StartTime },
  {
    label: "允许请假",
    path: SIPM.AllowLeave,
    component: "Tag",
    componentProps: {
      color: "green",
    },
  },
  {
    label: "成员列表",
    path: "memberList",
    render: () => {
      return (
        <Table
          columns={[
            { title: "姓名", align: "center", dataIndex: "userName" },
            { title: "学号", align: "center", dataIndex: "userNo" },
            { title: "班级", align: "center", dataIndex: "userClass" },
          ]}
          data={[
            { userNo: "2022070030101", userName: "史伟超", userClass: "2022级-软件工程-1班" },
            { userNo: "2022070030102", userName: "杨敏", userClass: "2022级-软件工程-1班" },
            { userNo: "2022070030103", userName: "何敏文", userClass: "2022级-软件工程-1班" },
            { userNo: "2022070030105", userName: "吴梦娜", userClass: "2022级-软件工程-1班" },
          ]}
        />
      );
    },
  },
];
